import datetime
import time

# 获取当前时间 2023-04-27 11:12:20.950135
now_time = datetime.datetime.now()
print(now_time)

# 时间的加减
# days=天，seconds=秒,minutes=分钟，hours=小时，weeks=周
res = now_time + datetime.timedelta(hours=3)
print(res)

# 时间替换
# year,month,day,hour,minute,second
res2 = res.replace(year=2000)  # 将年份 修改为 1999
print(res2)

# 将时间戳 修改为 日期格式
res3 = datetime.date.fromtimestamp(time.time())
print(res3)
